package com.ruoyi.web.controller.production.regulator;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.regulator.RegulatorType;
import com.ruoyi.production.service.regulator.IRegulatorTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调节剂类型Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/regulatorType")
public class RegulatorTypeController extends BaseController
{
    @Autowired
    private IRegulatorTypeService regulatorTypeService;

    /**
     * 查询调节剂类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorType:list')")
    @GetMapping("/list")
    public TableDataInfo list(RegulatorType regulatorType)
    {
        startPage();
        List<RegulatorType> list = regulatorTypeService.selectRegulatorTypeList(regulatorType);
        return getDataTable(list);
    }

    /**
     * 导出调节剂类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorType:export')")
    @Log(title = "调节剂类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RegulatorType regulatorType)
    {
        List<RegulatorType> list = regulatorTypeService.selectRegulatorTypeList(regulatorType);
        ExcelUtil<RegulatorType> util = new ExcelUtil<RegulatorType>(RegulatorType.class);
        return util.exportExcel(list, "调节剂类型数据");
    }

    /**
     * 获取调节剂类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorType:query')")
    @GetMapping(value = "/{regulatorTypeId}")
    public AjaxResult getInfo(@PathVariable("regulatorTypeId") Long regulatorTypeId)
    {
        return AjaxResult.success(regulatorTypeService.selectRegulatorTypeById(regulatorTypeId));
    }

    /**
     * 新增调节剂类型
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorType:add')")
    @Log(title = "调节剂类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RegulatorType regulatorType)
    {
        return toAjax(regulatorTypeService.insertRegulatorType(regulatorType));
    }

    /**
     * 修改调节剂类型
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorType:edit')")
    @Log(title = "调节剂类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RegulatorType regulatorType)
    {
        return toAjax(regulatorTypeService.updateRegulatorType(regulatorType));
    }

    /**
     * 删除调节剂类型
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorType:remove')")
    @Log(title = "调节剂类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regulatorTypeIds}")
    public AjaxResult remove(@PathVariable Long[] regulatorTypeIds)
    {
        return toAjax(regulatorTypeService.deleteRegulatorTypeByIds(regulatorTypeIds));
    }
}
